<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>我是第一个按钮</button>
    <button>我是第二个按钮</button>
    <button>我是第三个按钮</button>
    <script>
        var btnEle1 = document.querySelector("button");
        var btnEle2 = document.querySelectorAll("button")[1];
        var btnEle3 = document.querySelectorAll("button")[2];
        btnEle1.onclick = function (){
            window.open("http://www.baidu.com");
        }
        btnEle2.onclick = function (){
            window.close() ; 
        }
        btnEle3.onclick = function (){
            // window.location.href = "http://www.baidu.com" ; 
            console.log(window.location.href);
        }
        
    </script>
</body>
</html>